package at.socialconference.backend.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "t_relations")
public class Relations implements Insertable {

	@Id
	private RelationPK primaryKey = new RelationPK();

	@SuppressWarnings("unused")
	@Column(name = "userid_a", nullable = false, updatable = false, insertable = false)
	private Integer userid_a;

	@SuppressWarnings("unused")
	@Column(name = "userid_b", nullable = false, updatable = false, insertable = false)
	private Integer userid_b;

	@Column(name = "accepted", nullable = false, updatable = false, insertable = false)
	private Boolean isAccepted;

	public User getUserA() {
		return primaryKey.getUserA();
	}

	public User getUserB() {
		return primaryKey.getUserB();
	}

	public void setIsAccepted(boolean _isAccepted) {
		this.isAccepted = new Boolean(_isAccepted);
	}

	public boolean getIsAccepted() {
		return isAccepted.booleanValue();
	}
}

@Embeddable
class RelationPK implements Serializable {
	private static final long serialVersionUID = 1L;

	public RelationPK() {}

	@ManyToOne
	private User userid_a;

	@ManyToOne
	private User userid_b;

	public User getUserA() {
		return userid_a;
	}

	public void setUserA(User userA) {
		this.userid_a = userA;
	}

	public User getUserB() {
		return userid_b;
	}

	public void setUserB(User userB) {
		this.userid_b = userB;
	}
}